package edu.zut.controller;

import edu.zut.pojo.Employee;
import edu.zut.service.EmpService;
import edu.zut.service.impl.EmpServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

//根据员工姓名查询信息
@WebServlet(name = "QueryEmpServlet", value = "/emp/query")
public class QueryEmpServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String emp_name = request.getParameter("emp_name");
        EmpService empService = new EmpServiceImpl();
        List<Employee> employees = empService.queryEmpByName(emp_name);
        request.setAttribute("empList",employees);
        request.getRequestDispatcher("/view/home.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
